﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using InvoiceChecking.Data;
using InvoiceChecking.Settings.BusinessLayer;

public partial class Admin_ReportReceive : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            tb_ReceiveDate.Text = DateTime.Now.ToString("dd-MMM-yyyy");
            btn_Refresh_Click(null, null);
        }
    }

    protected void btn_Refresh_Click(object sender, ImageClickEventArgs e)
    {
        Invoices.TitleDataTable dsTitle = new Invoices.TitleDataTable();
        HttpCookie conCookie = Request.Cookies["ICConnectionString"];
        if (conCookie != null)
        {
            //ServiceFacade.SettingsHelper.ReceiveInvoicesTitle = "THE DAILY  INVOICES RECEIVING REPORT";
            dsTitle.AddTitleRow(ServiceFacade.SettingsHelper.ReceiveInvoicesTitle, conCookie.Value);
            DataSet ds = DataRepository.Provider.ExecuteDataSet("ICReport_ReceiveInvoices", DateTime.Parse(tb_ReceiveDate.Text));
            ReportViewer1.LocalReport.DataSources["Invoices_Title"].Value = dsTitle;
            ReportViewer1.LocalReport.DataSources["Invoices_Receive"].Value = ds.Tables[0];
            ReportViewer1.LocalReport.DataSources["Invoices_ReceiveSum"].Value = ds.Tables[1];
            ReportViewer1.DataBind();
        }
    }
}

